package app.species;

import sim.util.*;
import sim.engine.*;

public class PredatorCreator extends EntityCreator{

	/**
	 * 
	 */
	private static final long serialVersionUID = -9164238388683207011L;

	public PredatorCreator(int interval, SpawnPoint[] spoints){

		super(interval, spoints);

	}

	public void step(SimState state){

		super.step(state);

		if(this.timeSinceLastSpawn >= this.spawnInterval && this.spawnPoints.length > 0){

			SpeciesSim sim = (SpeciesSim)state;
			MutableDouble2D initPosition = this.spawnPoints[sim.random.nextInt(this.spawnPoints.length)].getRandomLocation(sim.random);

			Predator newPred = new Predator(initPosition, new MutableDouble2D(0, 0));

			sim.predators.setObjectLocation(newPred, new Double2D(initPosition));
			newPred.stoppable = sim.schedule.scheduleRepeating(newPred);

			this.timeSinceLastSpawn = 0;

		}

	}

}
